<!DOCTYPE html>
<html>

<head>
    <title>表单输入绑定</title>

    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

</head>

<body>
    <!-- 文本 -->
    <div id="app-1">
        <input v-model="message" placeholder="edit me">
        <p>Message is: {{ message }}</p>

        <hr>

        <!-- 多行文本 -->
        <span>Multiline message is:</span>
        <p style="white-space: pre-line;">{{ message2 }}</p>
        <br>
        <textarea v-model="message2" placeholder="add multiple lines"></textarea>

        <hr>

        <!-- 复选框 -->
        <input type="checkbox" id="checkbox" v-model="checked">
        <label for="checkbox">{{ checked }}</label>
    </div>

    <hr>

    <div id='example-3'>
        <input type="checkbox" id="jack" value="Jack" v-model="checkedNames">
        <label for="jack">Jack</label>
        <input type="checkbox" id="john" value="John" v-model="checkedNames">
        <label for="john">John</label>
        <input type="checkbox" id="mike" value="Mike" v-model="checkedNames">
        <label for="mike">Mike</label>
        <br>
        <span>Checked names: {{ checkedNames }}</span>
    </div>

    <hr>

    <!-- 单选按钮 -->
    <div id="example-4">
        <input type="radio" id="one" value="One" v-model="picked">
        <label for="one">One</label>
        <br>
        <input type="radio" id="two" value="Two" v-model="picked">
        <label for="two">Two</label>
        <br>
        <span>Picked: {{ picked }}</span>
    </div>

    <hr>

    <!-- 选择框 -->
    <div id="example-5">
        <select v-model="selected">
            <option disabled value="">请选择</option>
            <option>A</option>
            <option>B</option>
            <option>C</option>
        </select>
        <span>Selected: {{ selected }}</span>
    </div>

    <div id="example-6">
        <select v-model="selected" multiple style="width: 50px;">
            <option>A</option>
            <option>B</option>
            <option>C</option>
        </select>
        <br>
        <span>Selected: {{ selected }}</span>
    </div>


    <script>
        var app1 = new Vue({
            el: '#app-1',
            data: {
                message: "",
                message2: "",
                checked: false
            }
        });

        new Vue({
            el: '#example-3',
            data: {
                checkedNames: []
            }
        });

        new Vue({
            el: '#example-4',
            data: {
                picked: ''
            }
        });

        new Vue({
            el: '#example-5',
            data: {
                selected: ''
            }
        });

        new Vue({
            el: '#example-6',
            data: {
                selected: []
            }
        });
    </script>
</body>

</html>